export class DomUtils {

    /**
     * 判断一个元素是否在视野中
     * @param element 元素
     * @returns {boolean}
     */
    static isInView = (element) => {
        if (!element) {
            return false
        }
        const {bottom, top} = element.getBoundingClientRect();
        return (bottom >= 0 && bottom <= window.innerHeight) || (top >= 0 && top <= window.innerHeight) || (top < 0 && bottom > window.innerHeight);
    }

    // 滚动到顶部
    static  scrollTop = () => window.scrollTo({top: 0, behavior: 'smooth'})
}